package com.ruoyi.system.mapper.evaluation;

import com.ruoyi.system.domain.evaluation.Complaint;
import com.ruoyi.system.domain.evaluation.ComplaintandStore;
import com.ruoyi.system.domain.evaluation.Suggestion;
import com.ruoyi.system.domain.evaluation.SuggestionEntity;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface SuggestionMapper {
    @Select("select * from ry.suggestion")
    List<Complaint> selectSuggestion();
    @Select("select s.id,s.store_id,s.content,s.name ,s.department,s.tel,s.time,st.name as 'storeName',l.name as 'locationName' from suggestion s left join store st on st.id=s.store_id left join location l on l.id=st.location_id ")
    List<SuggestionEntity> selectSuggestionEntity();
    @Select("<script>" +
            "select s.id,s.store_id,s.content,s.name ,s.department,s.tel,s.time,st.name as 'storeName',l.name as 'locationName' from suggestion s left join store st on st.id=s.store_id left join location l on l.id=st.location_id where s.id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>"+
            " #{id}" +
            "</foreach>  order by s.time desc " +
            "</script>")
    List<SuggestionEntity> selectSuggestionExport(Long[] ids);

    //删除数据
    @Delete("<script>" +
            "delete from ry.suggestion where id in" +
            "<foreach collection='array' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            "</script>")
    int deleteSuggestion(Long[] ids);

    @Select("select s.id,s.store_id,s.content,s.name ,s.department,s.tel,s.time,st.name as 'storeName',l.name as 'locationName' from suggestion s left join store st on st.id=s.store_id left join location l on l.id=st.location_id where st.location_id=#{location_id} order by time desc")
    List<SuggestionEntity> selectSuggestionByLocation_id(String location_id);
    @Select("select s.id,s.store_id,s.content,s.name ,s.department,s.tel,s.time,st.name as 'storeName',l.name as 'locationName' from suggestion s left join store st on st.id=s.store_id left join location l on l.id=st.location_id where st.name=#{storeName} order by time desc")
    List<SuggestionEntity> selectSuggestionByStoreName(String storeName);
}
